<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绿能充 - 用户管理</title>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        :root {
            --primary-color: #00a896;
            --secondary-color: #02c39a;
            --dark-color: #05668d;
            --light-color: #f0f3bd;
            --accent-color: #028090;
            --text-dark: #333;
            --text-light: #f8f9fa;
            --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Noto Sans SC', sans-serif;
            color: var(--text-dark);
            background-color: #f9f9f9;
            min-height: 100vh;
            display: flex;
        }

        /* 侧边栏样式 - 与dashboard一致 */
        .sidebar {
            width: 250px;
            background: linear-gradient(135deg, var(--dark-color) 0%, var(--primary-color) 100%);
            color: white;
            padding: 20px 0;
            height: 100vh;
            position: fixed;
            box-shadow: var(--shadow);
            z-index: 100;
        }

        .sidebar-header {
            padding: 0 20px 20px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            margin-bottom: 20px;
        }

        .sidebar-header .logo {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }

        .sidebar-header .logo-icon {
            width: 40px;
            height: 40px;
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 18px;
            color: var(--light-color);
        }

        .sidebar-header h3 {
            font-size: 1.2rem;
            font-weight: 500;
            margin: 0;
        }

        .sidebar-header p {
            font-size: 0.8rem;
            opacity: 0.8;
            margin: 0;
        }

        .nav-menu {
            list-style: none;
            padding: 0 15px;
        }

        .nav-item {
            margin-bottom: 5px;
        }

        .nav-link {
            display: flex;
            align-items: center;
            padding: 12px 15px;
            color: rgba(255, 255, 255, 0.8);
            text-decoration: none;
            border-radius: 8px;
            transition: var(--transition);
        }

        .nav-link:hover, .nav-link.active {
            background-color: rgba(255, 255, 255, 0.1);
            color: white;
        }

        .nav-link i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
            font-size: 16px;
        }

        .nav-link .badge {
            margin-left: auto;
            background-color: var(--light-color);
            color: var(--dark-color);
            font-size: 0.7rem;
            padding: 3px 6px;
        }

        .user-profile {
            position: absolute;
            bottom: 20px;
            left: 0;
            width: 100%;
            padding: 0 20px;
        }

        .user-info {
            display: flex;
            align-items: center;
            padding: 10px;
            background-color: rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            cursor: pointer;
            transition: var(--transition);
        }

        .user-info:hover {
            background-color: rgba(255, 255, 255, 0.2);
        }

        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 14px;
        }

        .user-name {
            font-size: 0.9rem;
            font-weight: 500;
            margin-bottom: 2px;
        }

        .user-role {
            font-size: 0.7rem;
            opacity: 0.8;
        }

        /* 主内容区样式 */
        .main-content {
            flex: 1;
            margin-left: 250px;
            padding: 30px;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
        }

        .page-title h1 {
            font-size: 1.8rem;
            font-weight: 600;
            color: var(--dark-color);
            margin-bottom: 5px;
        }

        .page-title p {
            color: #777;
            font-size: 0.9rem;
            margin: 0;
        }

        .header-actions {
            display: flex;
            gap: 10px;
        }

        .btn {
            padding: 8px 16px;
            border-radius: 8px;
            font-size: 0.9rem;
            font-weight: 500;
            border: none;
            cursor: pointer;
            transition: var(--transition);
            display: flex;
            align-items: center;
        }

        .btn i {
            margin-right: 6px;
        }

        .btn-primary {
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            color: white;
            box-shadow: 0 4px 15px rgba(0, 168, 150, 0.3);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(0, 168, 150, 0.4);
        }

        .btn-outline {
            background: transparent;
            border: 1px solid #ddd;
            color: #555;
        }

        .btn-outline:hover {
            background-color: #f5f5f5;
        }

        .btn-danger {
            background: linear-gradient(to right, #f44336, #ff9800);
            color: white;
            box-shadow: 0 4px 15px rgba(244, 67, 54, 0.3);
        }

        .btn-danger:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(244, 67, 54, 0.4);
        }

        /* 搜索和筛选区域 */
        .filter-section {
            background-color: white;
            border-radius: 12px;
            padding: 20px;
            box-shadow: var(--shadow);
            margin-bottom: 20px;
        }

        .filter-row {
            display: flex;
            gap: 15px;
            margin-bottom: 15px;
        }

        .filter-group {
            flex: 1;
        }

        .filter-group label {
            display: block;
            margin-bottom: 8px;
            font-size: 0.9rem;
            color: #555;
            font-weight: 500;
        }

        .form-control {
            width: 100%;
            padding: 10px 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 0.9rem;
            transition: var(--transition);
        }

        .form-control:focus {
            border-color: var(--primary-color);
            outline: none;
            box-shadow: 0 0 0 3px rgba(0, 168, 150, 0.1);
        }

        .form-select {
            appearance: none;
            background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
            background-repeat: no-repeat;
            background-position: right 10px center;
            background-size: 1em;
        }

        /* 表格整体样式 */
        .user-management-table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
            font-size: 14px;
        }

        /* 表头样式 */
        .table-header {
            background-color: #f8f9fa;
        }

        .table-header th {
            padding: 12px 15px;
            font-weight: 600;
            color: #495057;
            border-bottom: 2px solid #e9ecef;
        }

        /* 表格行样式 */
        .user-row td {
            padding: 12px 15px;
            vertical-align: middle;
            border-bottom: 1px solid #e9ecef;
        }

        .user-row:hover {
            background-color: #f8f9fa;
        }

        /* 用户信息区域 */
        .user-info {
            display: flex;
            align-items: center;
        }

        .user-avatar {
            margin-right: 10px;
        }

        .avatar-img, .default-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
        }

        .default-avatar {
            background-color: #f0f3bd;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #05668d;
        }

        .user-details {
            line-height: 1.4;
        }

        .username {
            font-weight: 500;
        }

        .real-name {
            font-size: 12px;
            color: #6c757d;
        }

        /* 联系方式 */
        .contact-info {
            line-height: 1.4;
        }

        .phone {
            font-weight: 500;
        }

        .email {
            font-size: 12px;
            color: #6c757d;
        }

        /* 余额 */
        .balance {
            font-weight: 500;
            color: #28a745;
        }

        /* 角色标签 */
        .role-badge {
            display: inline-block;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: 500;
        }

        .role-user {
            background-color: #e0f7fa;
            color: #00a896;
        }

        .role-admin {
            background-color: #e3f2fd;
            color: #2196f3;
        }

        .role-tester {
            background-color: #fff8e1;
            color: #ff9800;
        }

        /* 状态标签 */
        .status-badge {
            display: inline-flex;
            align-items: center;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: 500;
        }

        .status-active {
            background-color: #e8f5e9;
            color: #4caf50;
        }

        .status-inactive {
            background-color: #ffebee;
            color: #f44336;
        }

        .status-badge i {
            margin-right: 4px;
            font-size: 12px;
        }

        /* 注册时间 */
        .register-time {
            line-height: 1.4;
        }

        .date {
            font-weight: 500;
        }

        .time {
            font-size: 12px;
            color: #6c757d;
        }

        /* 操作按钮 */
        .action-buttons {
            display: flex;
            gap: 8px;
        }

        .action-buttons .btn {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 4px;
            border: 1px solid transparent;
            transition: all 0.2s;
        }

        .btn-edit {
            color: #17a2b8;
            border-color: #17a2b8;
            background-color: rgba(23, 162, 184, 0.1);
        }

        .btn-edit:hover {
            background-color: rgba(23, 162, 184, 0.2);
        }

        .btn-reset {
            color: #6c757d;
            border-color: #6c757d;
            background-color: rgba(108, 117, 125, 0.1);
        }

        .btn-reset:hover {
            background-color: rgba(108, 117, 125, 0.2);
        }

        .btn-delete {
            color: #dc3545;
            border-color: #dc3545;
            background-color: rgba(220, 53, 69, 0.1);
        }

        .btn-delete:hover {
            background-color: rgba(220, 53, 69, 0.2);
        }

        .btn-detail {
            color: #6f42c1;
            border-color: #6f42c1;
            background-color: rgba(111, 66, 193, 0.1);
        }

        .btn-detail:hover {
            background-color: rgba(111, 66, 193, 0.2);
        }

        /* 表格样式 */
        .card {
            background-color: white;
            border-radius: 12px;
            box-shadow: var(--shadow);
            padding: 20px;
            margin-bottom: 20px;
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 1px solid #eee;
        }

        .card-header h3 {
            font-size: 1.2rem;
            font-weight: 600;
            margin: 0;
            color: var(--dark-color);
        }

        .table-responsive {
            overflow-x: auto;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #eee;
        }

        th {
            font-weight: 500;
            color: #555;
            font-size: 0.9rem;
            background-color: #f9f9f9;
        }

        tr:hover {
            background-color: #f9f9f9;
        }

        .badge {
            display: inline-block;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.75rem;
            font-weight: 500;
        }

        .badge-success {
            background-color: #e8f5e9;
            color: #4caf50;
        }

        .badge-warning {
            background-color: #fff8e1;
            color: #ff9800;
        }

        .badge-danger {
            background-color: #ffebee;
            color: #f44336;
        }

        .badge-info {
            background-color: #e3f2fd;
            color: #2196f3;
        }

        .badge-primary {
            background-color: #e0f7fa;
            color: #00a896;
        }

        /* 分页样式 */
        .pagination {
            display: flex;
            justify-content: center;
            margin-top: 20px;
        }

        .page-item {
            margin: 0 5px;
        }

        .page-link {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            border-radius: 8px;
            border: 1px solid #ddd;
            color: #555;
            text-decoration: none;
            transition: var(--transition);
        }

        .page-link:hover {
            background-color: #f5f5f5;
        }

        .page-item.active .page-link {
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            color: white;
            border-color: transparent;
        }

        /* 操作按钮 */
        .action-buttons {
            display: flex;
            gap: 8px;
        }

        .btn-sm {
            padding: 6px 12px;
            font-size: 0.8rem;
        }

        .btn-icon {
            width: 32px;
            height: 32px;
            padding: 0;
            justify-content: center;
        }

        /* 模态框样式 */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }

        .modal-content {
            background-color: white;
            border-radius: 12px;
            width: 100%;
            max-width: 500px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            animation: modalFadeIn 0.3s ease-out;
        }

        @keyframes modalFadeIn {
            from {
                opacity: 0;
                transform: translateY(-20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .modal-header {
            padding: 20px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-header h3 {
            margin: 0;
            font-size: 1.3rem;
            color: var(--dark-color);
        }

        .modal-close {
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            color: #777;
        }

        .modal-body {
            padding: 20px;
        }

        .modal-footer {
            padding: 15px 20px;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }

        /* 响应式设计 */
        @media (max-width: 992px) {
            .sidebar {
                width: 70px;
                overflow: hidden;
            }

            .sidebar-header h3,
            .sidebar-header p,
            .nav-link span,
            .user-name,
            .user-role {
                display: none;
            }

            .sidebar-header {
                padding: 15px 10px;
            }

            .nav-link {
                justify-content: center;
                padding: 12px 0;
            }

            .nav-link i {
                margin-right: 0;
                font-size: 18px;
            }

            .main-content {
                margin-left: 70px;
            }
        }

        @media (max-width: 768px) {
            .filter-row {
                flex-direction: column;
            }

            .header {
                flex-direction: column;
                align-items: flex-start;
                gap: 15px;
            }
        }

        @media (max-width: 576px) {
            .main-content {
                padding: 20px 15px;
            }

            .action-buttons {
                flex-direction: column;
                gap: 5px;
            }

            .btn-sm {
                width: 100%;
            }
        }
    </style>
</head>
<body>
<!-- 侧边导航栏 -->
<div class="sidebar">
    <div class="sidebar-header">
        <div class="logo">
            <div class="logo-icon">
                <i class="fas fa-charging-station"></i>
            </div>
            <div>
                <h3>绿能充</h3>
                <p>管理员面板</p>
            </div>
        </div>
    </div>

    <ul class="nav-menu">
        <li class="nav-item">
            <a href="/admin/dashboard" class="nav-link">
                <i class="fas fa-tachometer-alt"></i>
                <span>仪表盘</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/user/list" class="nav-link active">
                <i class="fas fa-users"></i>
                <span>用户管理</span>
                <span class="badge" th:text="${newUserCount}">5</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/pile/list" class="nav-link">
                <i class="fas fa-charging-station"></i>
                <span>充电桩管理</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/report/list" class="nav-link">
                <i class="fas fa-list-alt"></i>
                <span>充电记录</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/fault/list" class="nav-link">
                <i class="fas fa-exclamation-triangle"></i>
                <span>故障报告</span>
                <span class="badge">3</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/settings" class="nav-link">
                <i class="fas fa-cog"></i>
                <span>系统设置</span>
            </a>
        </li>
    </ul>

    <div class="user-profile">
        <div class="user-info">
            <div class="user-avatar">
                <i class="fas fa-user"></i>
            </div>
            <div>
                <div class="user-name">管理员</div>
                <div class="user-role">超级管理员</div>
            </div>
        </div>
    </div>
</div>

<!-- 主内容区 -->
<div class="main-content">
    <div class="header">
        <div class="page-title">
            <h1>用户管理</h1>
            <p>管理系统所有注册用户，共 <span>${totalUsers}</span> 位用户</p>
        </div>
        <div class="header-actions">
            <button class="btn btn-primary">
                <a href="${pageContext.request.contextPath}/admin/user/add">
                    <i class="fas fa-plus"></i> 添加用户
                </a>
            </button>
            <button class="btn btn-outline">
                <i class="fas fa-download"></i> 导出
            </button>
        </div>
    </div>

    <!-- 搜索和筛选区域 -->
    <div class="filter-section">
        <form action="/admin/user/list" method="get">
            <div class="filter-row">
                <div class="filter-group">
                    <label for="search">搜索用户</label>
                    <input type="text" id="search" name="keyword" class="form-control" placeholder="用户名/手机号/邮箱..." th:value="${param.keyword}">
                </div>
                <div class="filter-group">
                    <label for="status">用户状态</label>
                    <select id="status" name="status" class="form-control form-select">
                        <option value="">全部状态</option>
                        <option value="1" th:selected="${param.status == '1'}">正常</option>
                        <option value="0" th:selected="${param.status == '0'}">禁用</option>
                    </select>
                </div>
            </div>
            <div class="filter-row">
                <div class="filter-group">
                    <label for="role">用户角色</label>
                    <select id="role" name="role" class="form-control form-select">
                        <option value="">全部角色</option>
                        <option value="0" th:selected="${param.role == '0'}">普通用户</option>
                        <option value="1" th:selected="${param.role == '1'}">管理员</option>
                        <option value="2" th:selected="${param.role == '2'}">测试员</option>
                    </select>
                </div>
                <div class="filter-group">
                    <label for="date">注册时间</label>
                    <input type="date" id="date" name="registerDate" class="form-control" th:value="${param.registerDate}">
                </div>
            </div>
            <div style="display: flex; justify-content: flex-end; gap: 10px;">
                <button type="reset" class="btn btn-outline">重置</button>
                <button type="submit" class="btn btn-primary">搜索</button>
            </div>
        </form>
    </div>

    <!-- 用户表格 -->
    <div class="card">
        <div class="card-header">
            <h3>用户列表</h3>
            <div class="header-actions">
                <select class="form-control form-select" style="width: auto; margin-right: 10px;">
                    <option>每页10条</option>
                    <option>每页25条</option>
                    <option>每页50条</option>
                </select>
            </div>
        </div>
        <div class="table-responsive">
            <table class="table user-management-table">
                <thead class="table-header">
                <tr>
                    <th width="5%">ID</th>
                    <th width="15%">用户名</th>
                    <th width="15%">联系方式</th>
                    <th width="10%">余额</th>
                    <th width="10%">角色</th>
                    <th width="10%">状态</th>
                    <th width="15%">注册时间</th>
                    <th width="20%">操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${users}" var="user">
                    <tr class="user-row">
                        <td class="text-center">${user.id}</td>
                        <td>
                            <div class="user-info">
                                <div class="user-avatar">
                                    <c:choose>
                                        <c:when test="${not empty user.avatar}">
                                            <img src="${user.avatar}" alt="用户头像" class="avatar-img">
                                        </c:when>
                                        <c:otherwise>
                                            <div class="default-avatar">
                                                <i class="fas fa-user"></i>
                                            </div>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                                <div class="user-details">
                                    <div class="username">${user.username}</div>
                                    <c:if test="${not empty user.realName}">
                                        <div class="real-name">${user.realName}</div>
                                    </c:if>
                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="contact-info">
                                <div class="phone">${user.phone}</div>
                                <div class="email">${user.email}</div>
                            </div>
                        </td>
                        <td class="text-right">
                            <div class="balance">¥${user.balance}</div>
                        </td>
                        <td>
                    <span class="role-badge ${user.role == 0 ? 'role-user' : user.role == 1 ? 'role-admin' : 'role-tester'}">
                            ${user.role == 0 ? '普通用户' : user.role == 1 ? '管理员' : '测试员'}
                    </span>
                        </td>
                        <td>
                    <span class="status-badge ${user.status == 1 ? 'status-active' : 'status-inactive'}">
                        <i class="fas ${user.status == 1 ? 'fa-check-circle' : 'fa-times-circle'}"></i>
                        ${user.status == 1 ? '正常' : '禁用'}
                    </span>
                        </td>
                        <td>
                            <div class="register-time">
                                <div class="date"><fmt:formatDate value="${user.createTime}" pattern="yyyy-MM-dd"/></div>
                                <div class="time"><fmt:formatDate value="${user.createTime}" pattern="HH:mm:ss"/></div>
                            </div>
                        </td>
                        <td>
                            <div class="action-buttons">
                                <a href="${pageContext.request.contextPath}/admin/user/edit/${user.id}"
                                   class="btn btn-edit" title="编辑">
                                    <i class="fas fa-edit"></i>
                                </a>
                                <a href="${pageContext.request.contextPath}/admin/user/reset-password/${user.id}"
                                   class="btn btn-reset" title="重置密码">
                                    <i class="fas fa-key"></i>
                                </a>
                                <a href="${pageContext.request.contextPath}/admin/user/delete/${user.id}"
                                   class="btn btn-delete" title="删除"
                                   onclick="return confirm('确定要删除用户 ${user.username} 吗？此操作不可恢复！')">
                                    <i class="fas fa-trash-alt"></i>
                                </a>
                                <a href="${pageContext.request.contextPath}/admin/user/detail/${user.id}"
                                   class="btn btn-detail" title="详情">
                                    <i class="fas fa-info-circle"></i>
                                </a>
                            </div>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>

        <!-- 分页 -->
        <div class="pagination">
            <div class="page-item">
                <a href="#" class="page-link">
                    <i class="fas fa-angle-left"></i>
                </a>
            </div>
            <div class="page-item active">
                <a href="#" class="page-link">1</a>
            </div>
            <div class="page-item">
                <a href="#" class="page-link">2</a>
            </div>
            <div class="page-item">
                <a href="#" class="page-link">3</a>
            </div>
            <div class="page-item">
                <a href="#" class="page-link">
                    <i class="fas fa-angle-right"></i>
                </a>
            </div>
        </div>
    </div>
</div>

<!-- 删除确认模态框 -->
<div id="deleteConfirmModal" class="modal">
    <div class="modal-content" style="max-width: 400px;">
        <div class="modal-header">
            <h3>确认删除</h3>
            <button class="modal-close" onclick="closeDeleteConfirmModal()">&times;</button>
        </div>
        <div class="modal-body">
            <p>确定要删除该用户吗？此操作不可撤销。</p>
        </div>
        <div class="modal-footer">
            <button class="btn btn-outline" onclick="closeDeleteConfirmModal()">取消</button>
            <button class="btn btn-danger" onclick="deleteUser()">确认删除</button>
        </div>
    </div>
</div>

<script>

    // 删除确认
    let currentUserIdToDelete = null;

    function confirmDelete(userId) {
        currentUserIdToDelete = userId;
        document.getElementById('deleteConfirmModal').style.display = 'flex';
    }

    function closeDeleteConfirmModal() {
        document.getElementById('deleteConfirmModal').style.display = 'none';
    }

    function deleteUser() {
        // 这里添加删除逻辑
        console.log('删除用户:', currentUserIdToDelete);
        alert('用户已删除');
        closeDeleteConfirmModal();
    }

    // 启用/禁用用户
    function disableUser(userId) {
        if(confirm('确定要禁用该用户吗？')) {
            // 这里添加禁用逻辑
            console.log('禁用用户:', userId);
            alert('用户已禁用');
            location.reload();
        }
    }

    function enableUser(userId) {
        if(confirm('确定要启用该用户吗？')) {
            // 这里添加启用逻辑
            console.log('启用用户:', userId);
            alert('用户已启用');
            location.reload();
        }
    }
</script>
</body>
</html>